import Vue from 'vue'
import vuex from 'vuex'
import fun from "../util/function"

Vue.use(vuex)
const state = {
	fn_privacy:false, //隐私政策父级div
	privacy:false, //隐私政策组件
	isYk: false,
	zjzhInfo: {}, // 资金账号信息
	isShowNav: false,
	isMsyhLoadedBridge:false,//民生银行app桥接js加载  true  完成false 为完成
	liveindex: 1,
	isLive_particulars_box: false,
	clickLiveTab: false, //光大银行默认直播间tab没有点击
	userInfo: {},
	liveBackVideoSrc: '',
	liveNavCur: '', //直播nav 切换样式默认是直播
	roomTab: 1,
	liveRoomTab: 1,
	imState: 1,
	navClass: {
		listClass: "nav11",
		smallVideoClass: "nav22",
		caijingClass: "nav44",
		mineClass: "nav55"
	},
	ping: {},
	roomNum: {},
	SysOrgInfo: {}, //机构信息
	liveNavTabArray: [], //直播间tab标签数组
	bannerImgLink: "", //banner图片链接地址
	eduStore: {
		eduParentId: '', //一级ID
		eduChildId: '', //二级ID
		eduSonId: '', //三级ID
	},
	dotRedNum: '', //首页红点数据
	setRiskTip: true, //要风险提示
  isMobileTip: false, //不要 私加号码提示
  tipsShow: {
    accountTipShow: false, //关闭 资金账户类提示
    consultant: false, //关闭 投顾签约提示
    consulAgree: false, //是否 签署投顾协议提示
    whiteList: false, //是白名单用户？
    riskOver: false, //风险评估过期 提示
    riskLow: false, //风险评估等级不够 提示
  },
	setTip: null, //中银温馨提示框 动态组件
	roomRl: null, //直播间风险等级
	showGsTip: false, //国盛风险提示开关
	gyzqUpdatePrompt: false, //国元证券提示版本升级弹框显示隐藏
	gyzqLinkApp: false, //国元证券去app弹窗
	gyzqIsApp: false, //是否是国元证券app
	videoSrc: '', //视频播放src
	giftPanel: { //打赏礼物
		showGiftPanelFlag: false, //直播间送礼面板
		showSendMask: false, //送礼面板外的透明蒙版
		giftAmount: 1, //送礼数量
    enterRoomTime: 0, //进入直播间的开始计时时间
	},
	showMask:false,//回看,直播间透明蒙层，点击可关闭
	showSendGiftFlag: false, //礼物提示 不显示
	giftMessageQueue: [], //礼物提示动画队列
	clearDom: [{
			'imgClass': 'clear-screen',
			'text': '清除屏幕',
			'value': 'clearScreen',
			'listShow': true, //按钮是否隐藏
			'open': true,
		},
		{
			'imgClass': 'clear-animate',
			'text': '屏蔽特效',
			'value': 'clearAnimate',
			'listShow': true,
			'open': true,
		},
		{
			'imgClass': 'clear-message',
			'text': '屏蔽消息',
			'value': 'clearMessage',
			'listShow': true,
			'open': true,
		},
		{
			imgClass: "video-ratio0",
			text: "清晰度",
			value: "changeRatio",
			listShow: true, // 直播时展示
			open: true
		  }
	],
	roomTablesData: [], //更多列表： 视频 图文 图文链接
	currTime: 0, //当前视频播放的时长
	duration: 0, //视频播放总时长
	percentage:'',//视频播放百分比
  zxyhChangeRightHeight:'',//解决中信银行遮挡问题
	shopBtnShow: false,
  socketConnected:false,//点赞socked是否链接
  skinStoreInfo:{},//皮肤obj
  globalMask:{//全局透明蒙层，点击可关闭
    isShow:false,
    bgColor:'',
	zIndex:'',
	origin:'',//丁一20211231增加
  },
  videoIsPlay:false,
  videoControlsState:false,
  newInvitCard:[],//邀请卡数据
  isCollect:false,
  isGlobalMaskClick:true,//全局蒙版是否可以点击
  appVisible: false,
  floatVideoDirection:'',//浮窗Direction
  liveIsStart:false,//直播间是否开播   true  开播  false 未开播
	roomDetail: null, // 房间信息
	sourcePlat:'',// app  web  wx   wxwork   mini
	orgShareObj:null,
	globalPopupInfo: {
		type: 0,
		show: false,
		title: '您好，欢迎进入付费课程',
		curLecuerInfo: {},
		curCourseInfo: {},
		next: null,
		from: null,
	},
	axiosPlat:'',//app  wx    mini
	isMobile: false,
	videoErrorState: false, // 播放器异常状态
	setVideoState: "", //设置视频播放 暂停
	isShowMarginTop:false,
	appVersionBoolean:false,//true高于 false低于
}
//计算属性
//var getters = {
//	shownav(state) {
//		return state.isShowNav
//	}
//};
//管理mutations
const actions = {
	setYk: ({
		commit
	}, val) => {
		commit('setYk', val)
	},
	msyhLoadedBridge: ({
		commit
	}, val) => {
		commit('msyhLoadedBridge', val)
	},
	hideNav: ({
		commit,
		state
	}) => {
		commit('hideNav')
	},
	showNav: ({
		commit,
		state
	}) => {
		commit('showNav')
	},
	isBoxTrue: ({
		commit,
		state
	}) => {
		commit('isBoxTrue')
	},
	isBoxFalse: ({
		commit,
		state
	}) => {
		commit('isBoxFalse')
	},
	changeClickLiveTabFalse: ({
		commit,
		state
	}) => {
		commit('changeClickLiveTabFalse')
	},
	changeClickLiveTabBoolenTrue: ({
		commit,
		state
	}) => {
		commit('changeClickLiveTabBoolenTrue')
	},
	changeClickLiveTabBoolenFalse: ({
		commit,
		state
	}) => {
		commit('changeClickLiveTabBoolenFalse')
	},
	changeClickLiveTabTrue: ({
		commit,
		state
	}) => {
		commit('changeClickLiveTabTrue')
	},
	setUserInfo({
		commit
	}, userInfo) {
		commit('setUserInfo', userInfo)
	},
	setLiveBackVideoSrc: ({
		commit
	}, payload) => {
		commit('setLiveBackVideoSrc', payload)
	},
	setLiveBackVideoSrc11: ({
		commit
	}, payload) => {
		commit('setLiveBackVideoSrc11', payload)
	},
	setliveNavCur: ({
		commit
	}, payload) => {
		commit('setliveNavCur11', payload)
	},
	setRoomTab: ({
		commit
	}, tab) => {
		commit('setRoomTab', tab)
	},
	closeIm: ({
		commit
	}, tab) => {
		commit('closeIm', tab)
	},
	setRoomTab1: ({
		commit
	}, tab1) => {
		commit('setRoomTab1', tab1)
	},
	listClassClass: ({
		commit
	}, i) => {
		commit('listClassClass', i)
	},
	smallVideoClass: ({
		commit
	}, i) => {
		commit('smallVideoClass', i)
	},
	caijingClass: ({
		commit
	}, i) => {
		commit('caijingClass', i)
	},
	mineClass: ({
		commit
	}, i) => {
		commit('mineClass', i)
	},
	changeDotNum: ({
		commit
	}, i) => {
		commit('changeDotNum', i)
	},
	liveNavTabArray: ({
		commit
	}, i) => {
		commit('liveNavTabArray', i)
	},

	newInvitCard: ({
		commit
	}, i) => {
		commit('newInvitCard', i)
	},
	setEduParentId: ({
		commit
	}, i) => {
		commit('setEduParentId', i)
	},
	setEduChildId: ({
		commit
	}, i) => {
		commit('setEduChildId', i)
	},
	setEduSonId: ({
		commit
	}, i) => {
		commit('setEduSonId', i)
	},
	ansyTest({
		commit
	}) {
		var a = {
			aaa: 666
		}
		// commit('getTest')
		setTimeout(() => {
			commit('getTest', a)
		}, 1000)
	},
	SysOrgInfo: ({
		commit
	}, data) => {
		commit('SysOrgInfo', data)
	},
	dispatchBannerImgLink: ({
		commit
	}, data) => {
		commit('dispatchBannerImgLink', data)
	},
	setRiskTip: ({
		commit
	}, data) => {
		commit('setRiskTip', data)
	},
	setMobileTipTrue: ({
		commit,
		state
	}) => {
		commit('setMobileTipTrue')
	},
	setMobileTipFalse: ({
		commit,
		state
	}) => {
		commit('setMobileTipFalse')
	},
	setTipCom: ({
		commit
	}, data) => {
		commit('setTipCom', data)
  },
  accountTipShow: ({
		commit
	}, i) => {
		commit('accountTipShow', i)
  },
  consultant: ({
		commit
	}, i) => {
		commit('consultant', i)
  },
  consulAgree: ({
		commit
	}, i) => {
		commit('consulAgree', i)
  },
  whiteList: ({
		commit
	}, i) => {
		commit('whiteList', i)
  },
  riskOver: ({
		commit
	}, i) => {
		commit('riskOver', i)
  },
  riskLow: ({
		commit
	}, i) => {
		commit('riskLow', i)
	},
	getRoomRl: ({
		commit
	}, data) => {
		commit('getRoomRl', data)
	},
	setShowGsTip: ({
		commit
	}, data) => {
		commit('setShowGsTip', data)
  },
  showGiftPanelFlag: ({commit}, data) => {
		commit('showGiftPanelFlag', data)
  },
	showSendMask: ({
		commit
	}, data) => {
		commit('showSendMask', data)
	},
	showMask: ({
		commit
	}, data) => {
		commit('showMask', data)
	},
  globalMask: ({
  	commit
  }, data) => {
  	commit('globalMask', data)
  },
	giftAmount: ({
		commit
	}, data) => {
		commit('giftAmount', data)
	},
	videoSrc: ({
		commit
	}, src) => {
		commit('videoSrc', src)
	},
	enterRoomTime: ({
		commit
	}, data) => {
		commit('enterRoomTime', data)
	},
	giftAmountAdd: ({
		commit
	}) => {
		commit('giftAmountAdd')
	},
	giftAmountReduce: ({
		commit
	}) => {
		commit('giftAmountReduce')
	},
	giftMessageQueue: ({
		commit
	}, data) => {
		commit('giftMessageQueue', data)
	},
	showSendGiftFlag: ({
		commit
	}, data) => {
		commit('showSendGiftFlag', data)
	},
	changeClearData: ({
		commit
	}, index) => {
		commit('changeClearData', index)
	},
	getCurrTime: ({
		commit
	}, data) => {
		commit('getCurrTime', data)
	},
	getDuration: ({
		commit
	}, data) => {
		commit('getDuration', data)
	},
	getPercentage: ({
		commit
	}, data) => {
		commit('getPercentage', data)
	},
	changeRightHeight: ({
		commit
	}, data) => {
		commit('changeRightHeight', data)
  },
  getShopBtn: ({
		commit
	}, data) => {
		commit('getShopBtn', data)
	},
  getSocketConnected:({
		commit
	}, data) => {
		commit('getSocketConnected', data)
	},
  setSkinStoreObj:({
  	commit
  }, data) => {
  	commit('setSkinStoreObj', data)
  },
  setVideoIsPlayStatus:({
  	commit
  }, data) => {
  	commit('setVideoIsPlayStatus', data)
  },
  setVideoControlsState:({
  	commit
  }, data) => {
  	commit('setVideoControlsState', data)
  },
  setCollect:({
  	commit
  }, data) => {
  	commit('setCollect', data)
  },
  setIsGlobalMaskClick:({
  	commit
  }, data) => {
  	commit('setIsGlobalMaskClick', data)
  },
  setAppVisible:({
                   commit
                 }, data) => {
    commit('setAppVisible', data)
  },
   setFloatVideoDirection:({
                   commit
                 }, data) => {
    commit('setFloatVideoDirection', data)
  },
  setLiveIsStart:({
                   commit
                 }, data) => {
    commit('setLiveIsStart', data)
  }
}
//改变状态
const mutations = {
	setVideoState: (state, data) => {
		state.setVideoState = data;
	  }, 
	  // 修改播放器状态
	  setVideoErrorState: (state, bool) => {
		state.videoErrorState = bool;
	  },
	setGlobalPopupInfo: (state, info) => {
		state.globalPopupInfo = info;
	},
	setZjzhInfo: (state, info) => {
		state.zjzhInfo = info;
	},
	setYk: ({
		commit
	}, val) => {
		//console.log("setYk is ", val)
		state.isYk = val;
	},
	msyhLoadedBridge: ({
		commit
	}, val) => {
		state.isMsyhLoadedBridge = val;
	},
	hideNav: (state) => {
		state.isShowNav = false;
	},
	showNav: (state) => {
		state.isShowNav = true;
	},
	isBoxTrue: (state) => {
		state.isLive_particulars_box = true;
	},
	isBoxFalse: (state) => {
		state.isLive_particulars_box = false;
	},
	setUserInfo(state, userInfo) {
		state.userInfo = userInfo
	},
	setLiveBackVideoSrc: (state, payload) => {
		state.liveBackVideoSrc = payload;
	},
	setLiveBackVideoSrc11: (state, payload) => {
		state.liveBackVideoSrc = payload;
	},
	setliveNavCur11: ({
		commit
	}, payload) => {
		state.liveNavCur = payload
	},
	setRoomTab: ({
		commit
	}, tab) => {
		state.roomTab = tab
	},
	setRoomTab1: ({
		commit
	}, tab1) => {
		state.liveRoomTab = tab1
	},
	closeIm: ({
		commit
	}, tab1) => {
		state.imState = tab1
	},
	smallVideoClass: ({
		commit
	}, i) => {
		state.navClass.smallVideoClass = i;
	},
	listClassClass: ({
		commit
	}, i) => {
		state.navClass.listClass = i;
	},
	caijingClass: ({
		commit
	}, i) => {
		state.navClass.caijingClass = i;
	},
	mineClass: ({
		commit
	}, i) => {
		state.navClass.mineClass = i;
	},
	changeDotNum: ({
		commit
	}, i) => {
		state.dotRedNum = i;
	},
	liveNavTabArray: ({
		commit
	}, i) => {
		state.liveNavTabArray = i;
	},
	newInvitCard: ({
		commit
	}, i) => {
		state.newInvitCard = i;
	},
	SysOrgInfo: ({
		commit
	}, data) => {
		state.SysOrgInfo = data;
	},
	setEduParentId: ({
		commit
	}, data) => {
		state.eduStore.eduParentId = data;
	},
	setEduChildId: ({
		commit
	}, data) => {
		state.eduStore.eduChildId = data;
	},
	setEduSonId: ({
		commit
	}, data) => {
		state.eduStore.eduSonId = data;
	},
	dispatchBannerImgLink: ({
		commit
	}, data) => {
		state.bannerImgLink = data;
	},
	getTest: ({
		commit
	}, i) => {
		state.test = { ...state.test,
			...i
		};
	},
	setRiskTip: ({
		commit
	}, data) => {
		state.setRiskTip = data;
	},
	setMobileTipTrue: (state) => {
		state.isMobileTip = true;
	},
	setMobileTipFalse: (state) => {
		state.isMobileTip = false;
	},
	setTipCom: ({
		commit
	}, data) => {
		state.setTip = data;
  },
  accountTipShow: ({
		commit
	}, i) => {
		state.tipsShow.accountTipShow = i;
  },
  consultant: ({
		commit
	}, i) => {
		state.tipsShow.consultant = i;
  },
  consulAgree: ({
		commit
	}, i) => {
		state.tipsShow.consulAgree = i;
  },
  whiteList: ({
		commit
	}, i) => {
		state.tipsShow.whiteList = i;
  },
  riskOver: ({
		commit
	}, i) => {
		state.tipsShow.riskOver = i;
  },
  riskLow: ({
		commit
	}, i) => {
		state.tipsShow.riskLow = i;
	},
	getRoomRl: ({
		commit
	}, data) => {
		state.roomRl = data
		console.log(state.roomRl + "index.js")
	},
	setShowGsTip: ({
		commit
	}, data) => {
		state.showGsTip = data
	},
	setGyzqUpdatePrompt: ({
		commit
	}, val) => {
		state.gyzqUpdatePrompt = val;
	},
	setGyzqLinkApp: ({
		commit
	}, val) => {
		state.gyzqLinkApp = val;
	},
	setGyzqIsApp: ({
		commit
	}, val) => {
		state.gyzqIsApp = val;
  },
  showGiftPanelFlag: ({commit}, data) => {
    state.giftPanel.showGiftPanelFlag = data;
  },
	showSendMask: ({
		commit
	}, data) => {
		state.giftPanel.showSendMask = data;
	},
	showMask: ({
		commit
	}, data) => {
		state.showMask = data;
	},
  globalMask: ({
  	commit
  }, data) => {
  	//state.globalMask = data;
    state.globalMask.isShow = data.isShow;
    state.globalMask.bgColor = data.bgColor;
	state.globalMask.zIndex = data.zIndex;
	state.globalMask.origin = data.origin;
	state.globalMask.maskHeight = data.maskHeight;
  },
	videoSrc: (state, src) => {
		state.videoSrc = src;
	},
	giftAmount: ({
		commit
	}, data) => {
		state.giftPanel.giftAmount = data;
	},
	enterRoomTime: ({
		commit
	}, data) => {
		state.giftPanel.enterRoomTime = data;
	},
	giftAmountAdd: ({
		commit
	}) => {
    state.giftPanel.giftAmount++;
	},
	giftAmountReduce: ({
		commit
	}) => {
		state.giftPanel.giftAmount--;
	},
	giftMessageQueue: ({
		commit
	}, data) => {
		state.giftMessageQueue = data;
	},
	showSendGiftFlag: ({
		commit
	}, data) => {
		state.showSendGiftFlag = data;
	},
	getCurrTime: ({
		commit
	}, data) => {
		state.currTime = data;
	},
	getDuration: ({
		commit
	}, data) => {
		state.duration = data;
  },
  getPercentage: ({
	commit
}, data) => {
	state.percentage = data;
},
  changeRightHeight: ({
		commit
	}, data) => {
		state.zxyhChangeRightHeight = data;
	},
	changeClearData: ({commit}, index) => {
		state.clearDom[index].open = ! state.clearDom[index].open;
		if(state.clearDom[index].imgClass.includes('1')){
			state.clearDom[index].imgClass = state.clearDom[index].imgClass.substr(0,state.clearDom[index].imgClass.length-1)
		}else{
			state.clearDom[index].imgClass = state.clearDom[index].imgClass+'1'
    }
    switch (index){
      case 0:
        if(state.clearDom[index].text=='清除屏幕'){
          state.clearDom[index].text='打开屏幕'
        }else{
          state.clearDom[index].text='清除屏幕'
        }
        break;
      case 1:
        if (state.clearDom[index].listShow) {
          if(state.clearDom[index].text=='屏蔽特效'){
            state.clearDom[index].text='打开特效'
          }else{
            state.clearDom[index].text='屏蔽特效'
          }
        };
        break;
      case 2:
        if(state.clearDom[index].text=='屏蔽消息'){
        state.clearDom[index].text='打开消息'
        }else{
          state.clearDom[index].text='屏蔽消息'
        }
        break;
      default:
        break;
    }
  },
  getShopBtn: ({
		commit
	}, data) => {
    state.shopBtnShow = data;
	},
   getSocketConnected: ({
		commit
	}, data) => {
    state.socketConnected = data;
	},
  setSkinStoreObj: ({
  	commit
  }, data) => {
    state.skinStoreInfo = data;
  },
  setVideoIsPlayStatus: ({
  	commit
  }, data) => {
    state.videoIsPlay = data;
  },
  setVideoControlsState: ({
  	commit
  }, data) => {
    state.videoControlsState = data;
  },
  setCollect: ({
  	commit
  }, data) => {
    state.isCollect = data;
  },
  setIsGlobalMaskClick:({
  	commit
  }, data) => {
  	state.isGlobalMaskClick = data;
  },
  setAppVisible:({
                   commit
                 }, data) => {
    state.appVisible = data;
  },
  setFloatVideoDirection:({
                   commit
                 }, data) => {
    state.floatVideoDirection = data;
  },
  setLiveIsStart:({
                   commit
                 }, data) => {
    state.liveIsStart = data;
  },
	setRoomDetail(state, data) {//orgShareObj
		state.roomDetail = data
	},
	setSourcePlat:(state,data)=>{
	state.sourcePlat = data;
	},
	setOrgShareObj:(state,data)=>{
		state.orgShareObj = data;
	},
	setAxiosPlat:(state,data)=>{
		state.axiosPlat = data;
	},
	setIsMobile:(state,data)=>{
		state.isMobile = data
	  },
	  changeRatio: (state, index) => {
		const clearDom = state.clearDom[3];
		clearDom.open = index;
		clearDom.imgClass = "video-ratio" + index;
	  },
	  setShowMarginTop:(state,bol)=>{
		state.isShowMarginTop = bol;
	},
	setAppVersion:(state,bol)=>{
		state.appVersionBoolean = bol;
	},
};
const store = new vuex.Store({
	state,
	//getters,
	actions,
	mutations
});
//导出store对象
export default store;
